
<script type="text/javascript">
	function gotoeditpage(id) {
		var url = "<?php echo site_url($role.'/home/edit/').'/'; ?>" + id;
		document.location.href = url;
	}

	function gotodeletepage(id) {
		var url = "<?php echo site_url($role.'/home/delete/').'/'; ?>" + id;
		document.location.href = url;
	}

	$(document).ready(function() {
		$("#list").tablesorter({
			widthFixed: true,
			widgets: ['zebra']
		}).tablesorterPager({
			container: $(".pager")
		});
	});
</script>

<div id="main-content" class="prepend-1 span-19 last">
<?php 
	if ($deletestatus == 'success') {
		echo '<span class="info">Pengumuman berhasil dihapus.</span><br /><br />'; 
	} else if ($deletestatus == 'failed') {
		echo '<span class="error">Pengumuman gagal dihapus. Silakan coba beberapa saat lagi.</span><br /><br />';
	}
	if ($editrole == 'failed') {
		echo '<span class="error">Pengumuman hanya dapat diubah oleh pembuat pengumuman.</span><br /><br />';
	} else if ($deleterole == 'failed') {
		echo '<span class="error">Pengumuman hanya dapat dihapus oleh pembuat pengumuman.</span><br /><br />';
	}
?>
	<h3>Daftar Pengumuman</h3>
	<table border="1" id="list">
	<thead>
		<tr>
			<th>Judul</th>
			<th width="150">Di Poskan Oleh</th>
			<th width="150">Tanggal</th>
			<th width="180">Operasi</th>
		</tr>
	</thead>
	<tfoot>
		<?php echo $pager; ?>
	</tfoot>
	<tbody>
<?php
	$counter = 0; 
	foreach ($announcements as $announcement) : 
?>
		<tr>
			<td><?php echo anchor($role.'/home/index/'.$counter, $announcement->title); ?></td>
			<td><?php echo $announcement->creator; ?></td>
<?php 
	$counter += 1;
	$time = mysql_to_unix($announcement->date);
?>
			<td align="center"><?php echo mdate(DATE_FORMAT, $time); ?></td>
			<td align="center">
				<input type="button" class="submit" name="edit" value="Edit" onclick="gotoeditpage('<?php echo $announcement->id; ?>')" />
				<?php echo nbs().'|'.nbs(); ?>
				<input type="button" class="submit" name="delete" value="Delete" onclick="gotodeletepage('<?php echo $announcement->id; ?>');" />
			</td>
		</tr>
<?php endforeach; ?>
	</tbody>
	</table>
<br /><br />
</div>
